package 线程状态.线程守护;


public class test1 {
    public static void main(String[] args) {
        god god = new god();
        you you = new you();

        Thread thread = new Thread(god);
        thread.setDaemon(true);//设置守护线程
        System.out.println(thread.getPriority());
        thread.start();

        new Thread(you).start();

    }
}
//守护线程
class god implements Runnable{
    @Override
    public void run() {
        while (true){

            System.out.println("守护线程");
            try {
                Thread.sleep((long) 0.2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
//用户线程
class you implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println("用户线程");
        }
    }
}